"""debug"""
import subprocess

from diskcache import Cache

from lib.global_share import GlobalShare
from lib.logger import logger


def _show_cache_value():
    cache = Cache(GlobalShare.CACHE_DIR)
    locust_processes = cache.get("locust_processes")
    logger.debug(locust_processes)


def _get_locust_pid_list(target):
    command = f"ps -ef | grep locust | grep -- {target}"
    result = subprocess.run(
        command, shell=True, capture_output=True, text=True, check=True
    )
    output = result.stdout.strip()
    logger.debug(output.split())
    pid = int(output.split()[1].strip())
    logger.debug(pid)
    return pid


if __name__ == "__main__":
    pass
